import 'package:flutter/material.dart';
import '../model/category.dart';

class ChildCategory with ChangeNotifier {
  List<SubCategory> subCategories = [];
  String _categoryId =
      '2c9f6c946cd22d7b016cd74220b70040'; // 一级分类id、大分类id 4是白酒的id
  String _categorySubId = ''; // 二级分类id
  int _page = 1; // 分页数据

  // 设置二级菜单
  setChildCategory(List<SubCategory> list, String categoryId) {
    // 赋值
    _categoryId = categoryId;
    _categorySubId = '';
    _page = 1;

    SubCategory subCategory = SubCategory(
        mallSubId: '', mallCategoryId: '00', mallSubName: '全部', comments: null);

    subCategories = [subCategory];

    subCategories.addAll(list);

    notifyListeners();
  }

  // 更改二级菜单id
  setCategorySubId(String categorySubId) {
    print('二级分类 $categorySubId');
    _categorySubId = categorySubId;

    notifyListeners();
  }

  addPage() {
    _page++;
  }

  // 获取对应的值
  String get categoryId => _categoryId;
  String get categorySubId => _categorySubId;
  int get page => _page;
}
